<template>
    <div>
        <div class="title">管理员界面</div>
        <el-form :model="form" label-width="80px">
            <el-form-item label="账户">
                <el-input v-model="form.username" placeholder="请输入账号"></el-input>
            </el-form-item>
             <el-form-item label="密码">
                <el-input type="password" v-model="form.password" placeholder="请输入更改后的密码"></el-input>
            </el-form-item>
        </el-form>
        <el-button type="primary" size="mini" @click="back()">返回登录</el-button>
        <el-button type="primary" size="mini" @click="updatePwd()">更改密码</el-button>
    </div>
</template>

<script>
export default {
    data() {
        return {
            form:{
                username:'',
                password:''
            }
        }
    },
    methods:{
        //修改密码
        async updatePwd(){
            const res = await this.$http.get('/updatePwd',{params:this.form})
            // console.log(res)
            if(res.data.status != 200){
                this.$message.error(res.data.meta)
            }else{
                this.$message.success(res.data.meta)
                //清空输入框
                this.form.username = ''
                this.form.password = ''
            }
        },
        //返回登陆
        back(){
            this.$router.push('login')
        }
    }
}
</script>

<style lang="less" scoped>
.title{
    font-size: 20px;
    margin-bottom: 100px;
    position: relative;
    left: 40%;
}
.el-form{
    position: relative;
}
.el-button{
    float: right;
    margin-left: 47px;
}
</style>